package com.jeesite.modules.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 静态资源配置类
 * 专门用于配置头像和文件的静态资源访问
 */
//@Configuration
public class StaticResourceConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 配置头像资源映射
        registry.addResourceHandler("/js/avatars/**")
                .addResourceLocations("file:./userfiles/upload/avatars/")
                .setCachePeriod(3600);

        // 配置文件上传资源映射
        registry.addResourceHandler("/js/files/**")
                .addResourceLocations("file:./userfiles/upload/files/")
                .setCachePeriod(3600);

        System.out.println("=== StaticResourceConfig: 静态资源映射配置完成 ===");
    }
}
